home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / uberwidgets / uberwidget.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  3KB  |  82 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import sys
  5. import wx
  6. from types import NoneType
  7. from gui import skin
  8. import gui.native.extensions as gui
  9. import ctypes
  10. from ctypes import byref
  11. from ctypes import create_unicode_buffer
  12.  
  13. try:
  14.     uxtheme = ctypes.windll.uxtheme
  15.     OpenTheme = uxtheme.OpenThemeData
  16.     CloseTheme = uxtheme.CloseThemeData
  17.     DrawThemeBG = uxtheme.DrawThemeBackground
  18.     IsAppThemed = uxtheme.IsAppThemed
  19.     uxthemeable = True
  20. except:
  21.     uxthemeable = False
  22.  
  23.  
  24. class UberWidget(object):
  25.     
  26.     def __init__(self, nativekey):
  27.         self.uxthemeable = uxthemeable
  28.         self.nativekey = nativekey
  29.         self.nativetheme = None
  30.         self.Bind(wx.EVT_CLOSE, self.OnThisWidgetClose)
  31.  
  32.     
  33.     def SetSkinKey(self, key, update = False):
  34.         if not isinstance(key, (basestring, NoneType)):
  35.             raise TypeError('skin keys must be strings or NoneType; is %s' % type(key))
  36.         
  37.         if not not key:
  38.             if not skin.get('%s.mode' % key, ''):
  39.                 pass
  40.             if ''.lower() == 'native' or key.lower() == 'native':
  41.                 key = None
  42.             
  43.         self.skinkey = key
  44.         if update:
  45.             self.UpdateSkin()
  46.         
  47.  
  48.     
  49.     def OpenNativeTheme(self):
  50.         if hasattr(self, 'nativetheme') and self.nativetheme:
  51.             CloseTheme(self.nativetheme)
  52.         
  53.         
  54.         try:
  55.             self.nativetheme = None if OpenTheme else None
  56.             return bool(self.nativetheme)
  57.         except:
  58.             return False
  59.  
  60.  
  61.     
  62.     def CloseNativeTheme(self):
  63.         if self.nativetheme:
  64.             CloseTheme(self.nativetheme)
  65.             self.nativetheme = None
  66.         
  67.  
  68.     
  69.     def OnThisWidgetClose(self, event):
  70.         self.CloseNativeTheme()
  71.         event.Skip()
  72.  
  73.     
  74.     def DrawNativeLike(self, dc, part, state, rect, DrawNativeFallback = None):
  75.         if 'wxMSW' in wx.PlatformInfo and hasattr(self, 'nativetheme') and self.nativetheme:
  76.             DrawThemeBG(self.nativetheme, dc.GetHDC(), part, state, byref(rect.RECT), None)
  77.         elif DrawNativeFallback:
  78.             DrawNativeFallback(dc, part, state, rect)
  79.         
  80.  
  81.  
  82.